<template>
  <div class="redirect-container">
    <a-spin size="large" tip="正在刷新页面..." />
  </div>
</template>

<script setup>
import { onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();

/**
 * 重定向组件，用于处理页面刷新
 * 通过短暂停留后跳转回目标页面实现刷新效果
 */
onMounted(() => {
  // 获取目标路径（去掉 /redirect 前缀）
  const targetPath = route.path.replace('/redirect', '') || '/';

  // 获取查询参数
  const query = { ...route.query };
  delete query.t; // 移除时间戳参数

  // 短暂延迟后跳转，给用户看到加载动画
  router.replace({
    path: targetPath,
    query,
    replace: true,
  });
});
</script>

<style scoped>
.redirect-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: var(--theme-bg);
}
</style>
